package com.fileCenter.util;

import java.lang.reflect.Field;

import org.apache.commons.lang.StringUtils;

import com.fileCenter.pojo.Model;

public class DataTypeUtil {
	
	public static Class<?> getAttrType (Class<?> cls,String field) {
		if (null == cls && null == field) {
			return null;
		}
		
		Field[] fields = cls.getDeclaredFields();
		for (Field f : fields) {
			if (StringUtils.equals(f.getName(), field)) {
				return f.getType();
			}
		}
		
		return null;
	}
	
	public static void main(String[] args) {
		Field[] fields = Model.class.getDeclaredFields();
		
		for (Field f : fields){
			System.out.println(f.getName());
			System.out.println(f.getType());
			System.out.println(f.getType().getName());
		}
//		String s = "1";
//		Integer o = 0;
//		int i = (Integer)s;
//		System.out.println();
		Object obj = (getAttrType(Model.class,"name").cast("ss"));
		System.out.println(obj);
	}
}
